import React, { useImperativeHandle, useRef } from 'react'

function FunTest(props, fatherRef) {
    let selfRef = useRef()
    console.log('FunTest fatherRef: ', fatherRef);
    // 给一个ref对象的current属性指定值的
    useImperativeHandle(fatherRef,()=>{
        return {
            changeBorder:()=>{
                selfRef.current.style.border = '1px solid red';
            },
            changeColor:()=>{
                selfRef.current.style.color = 'red';
            }
        }
    })
    return (
        <div ref={selfRef}>FunTest</div>
    )
}

export default React.forwardRef(FunTest);
